package dev.ece.suit.hexmap;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import dev.ece.suit.hexmap.terrain.TerrainRenderer;
import dev.ece.util.lib.Vector2f;
import dev.ece.util.lib.Vector3f;

@Deprecated
public class HexMapWaterCell {

	/**地图坐标**/
	private int row;
	
	private int col;
	
	/**
	 * 顶点
	 */
	private final List<Vector3f> vertice = new ArrayList<Vector3f>();
	
	/**
	 * 纹理坐标
	 */
	private final List<Vector2f> uv = new ArrayList<Vector2f>();
	
	/**
	 * 渲染器
	 */
	private TerrainRenderer renderer;
	
	private int first;
	
	protected HexMapWaterCell(int row, int col) {
		this.row = row;
		this.col = col;
	}
	
	private HexMapWaterCell() {}
	
	public void setup() {
		renderer.setup();
		uv.clear();
	}

	public void render(HexMapWaterShader shader) {
		renderer.render(this.getFirst());
	}
	
	public static HexMapWaterCell createHexMapWaterCell(TerrainRenderer renderer, int row, int col) {
		HexMapWaterCell cell = new HexMapWaterCell();
		cell.renderer = renderer;
		cell.row = row;
		cell.col = col;
		return cell;
	}
	
	public List<Vector3f> getVertice() {
		return vertice;
	}

	public List<Vector2f> getUv() {
		return uv;
	}

	public TerrainRenderer getRenderer() {
		return renderer;
	}

	public int getRow() {
		return row;
	}

	public int getCol() {
		return col;
	}

	protected int getFirst() {
		return first;
	}

	protected void setFirst(int first) {
		this.first = first;
	}

	public void destroy() {
		vertice.clear();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder()
				.append(this.col).append(this.row).toHashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if(obj == null) {
			return false;
		}
		if(!(obj instanceof HexMapWaterCell)) {
			return false;
		}
		HexMapWaterCell cell = (HexMapWaterCell) obj;
		return new EqualsBuilder()
				.append(cell.col, col).append(cell.row, row).isEquals();
	}
	
}
